<?php
	include('header.php');
	$mongodb = OpenDB($CONFIG['MONGDB']);
	if (is_array($mongodb) && $mongodb['status'] == 'error') {
		$isConnection = 'false';
	} else {
		$isConnection = 'true';
		$sgk = $mongodb->selectDB($CONFIG['DB']);
		$indexCollection = $sgk->SelectCollection("index");
		$cursor = $indexCollection->find();
		$re = GetCursorArray($cursor);
	}
?>
<header class="jumbotron subhead" id="overview">
	<div class="container">
		<h1>数据明细</h1>
		<p class="lead">.................</p>
	</div>
</header>
<div class="container">
	<div class="notifications bottom-right"></div>
	<div class="row">
		<div class="col-md-10 col-md-offset-1">
			<table class="table table-striped table-condensed table-hover">
				<thead>
					<tr class="danger">
						<th>描述</th><th>数据量</th>
					</tr>
				</thead>
				<tbody>
					<?php
						$count = 0;
						if (isset($re)) {
							foreach ($re as $key => $value) {
								$a = sprintf('<tr class="info"><td>%s</td><td>%s</td></tr>', $value['excerpt'], number_format($value['count']));
								echo $a;
								$count += $value['count'];
							}
						}
						
					?>
				</tbody>
				<tfoot>
				<tr class="success">
					<td></td>
					<td>共<?=number_format_cn($count)?></td>
				</tr>
				</tfoot>
			</table>
		</div>
	</div>
</div>
<script>
	var a = "<?=$isConnection?>";
	if (a == 'false') {
		$('.notifications').notify({message:{text:'数据库连接失败'},type:'blackgloss'}).show();
	}
</script>
<?php include('foot.php'); ?>
